package com.hspedu.map_;

import java.util.Comparator;
import java.util.TreeMap;
@SuppressWarnings({"all"})
public class TreeMap01 {
    public static void main(String[] args) {
        TreeMap treeMap = new TreeMap(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                if (((String) o1).length() - ((String) o2).length() == 0) {
                    return -1;
                } else {
                    return 1;
                }
            }
        });
        treeMap.put("jack","杰克");
        treeMap.put("tom","汤姆");
        treeMap.put("kristina","克里斯蒂娜");
        treeMap.put("smith","斯密斯");
        System.out.println(treeMap);
    }
}
